public class miVector {
    int[] m;

    public miVector() {}
    
    public void generarVector(int tam){
        m = new int[tam];
        for(int i=0; i<tam; i++){
            m[i] = (int)(Math.random()*100);
        }
    }
    
    public void visualizarVector(){
        for(int i=0; i<m.length;i++){
            System.out.print(" "+m[i]);
        }
        System.out.println("");
    }
    
    public void ordenarBurbuja(){
        for(int i=m.length; i>0; i--){
            for(int j=0; j<(i-1); j++){
                if(m[j] > m[j+1]){
                    int aux = m[j];
                    m[j] = m[j+1];
                    m[j+1] = aux;
                }
            }
            //visualizarVector();
        }
    }
    
    public miVector Clonar(){
        miVector v = new miVector();
        v.generarVector(m.length);
        
        for(int i=0; i<m.length; i++){
            v.m[i] = m[i];
        }
        return v;
    }
    
    public static miVector Fusionar(miVector m1, miVector m2){
        miVector mF = new miVector();
        mF.generarVector(m1.m.length + m2.m.length);
        
        miVector t1 = new miVector();
        miVector t2 = new miVector();
        
        t1 = m1.Clonar();
        t2 = m2.Clonar();
        
        t1.ordenarBurbuja();
        t2.ordenarBurbuja();
        
        int cont1=0,cont2=0,cont = m1.m.length+m2.m.length;
        
        for(int i=0; i<cont; i++){
            if(cont1 != t1.m.length && cont2 != t2.m.length){
                if(t1.m[cont1] >= t2.m[cont2]){
                    mF.m[i] = t2.m[cont2];
                    cont2++;
                }else{
                    mF.m[i] = t1.m[cont1];
                    cont1++;
                }
            }
            else{
                if(cont1 == t1.m.length){
                    mF.m[i] = t2.m[cont2];
                    cont2++;
                }else{
                    mF.m[i] = t1.m[cont1];
                    cont1++;
                }
            }
        }
        
        return mF;
    }
}
